package com.hd.boot0407.controller;

import com.baomidou.kaptcha.Kaptcha;
import com.hd.boot0407.entity.User;
import com.hd.boot0407.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;

@Controller
@RequestMapping("/hello")
public class HelloController {
    @Autowired
    UserService userService;

    @GetMapping("/get/{id}")
    @ResponseBody
    public User getUserById(@PathVariable("id") Integer id){
       User byId = userService.getById(id);
        return byId;
    }
    @GetMapping("/test1")
    public String test1(HttpServletRequest request){
        ServletContext servletcontext = request.getServletContext();
        String realPath =servletcontext.getRealPath("/");
        return realPath;
    }

}
